<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/jquery-1.12.1.min.js" type="text/javascript" charset="utf-8"></script>
		<style>
			.c1{
				width: 500px;
				height: 200px;
				border: dashed 1px grey;
				background-color: #BACCD6;
				box-shadow: 20px 10px #C6D6DE;
			}
			
			button{
				display: inline-block;
				margin-top: 50px;	
			}
		</style>
		
		<script>
			
			$(function(){
				
				$("#btn1").click(function(){
					alert($("#bg").hasClass("c1"))
					//如果存在样式就不追加
					if($("#bg").hasClass("c1")){
						alert("已经存在样式")
					}else{
						alert("Else ")
						$("#bg").addClass("c1");
					}
					
				})
				
				$("#btn2").click(function(){
					if($("#bg").hasClass("c1")){
						$("#bg").removeClass("c1");
					}else{
						alert("已经不存在样式")
					}
				})
			})
			
		</script>
	</head>
	<body >
		<div id="bg" class="ccs">
			content  content  content  content  content  content  content  
			
		</div>
		
		<button id="btn1">添加样式</button>
		<button id="btn2">移除样式</button>
		
		
		
	</body>
</html>
